Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

336
Vistas
How to programmatically click on a button and after a particular time in Javascript and jQuery | Bypass popup blocking in web Browsers

I was developing an application that programmatically shows a popup after 5 seconds, but i found out that web browsers like firefox, chrome, internet explorer, etc. were blocking the popup.

Popup blocking In the past, evil sites abused popups a lot. A bad page could open tons of popup windows with ads. So now most browsers try to block popups and protect the user.

Most browsers block popups if they are called outside of user-triggered event handlers like onclick

By default modern web browsers block popups triggered by a function or code. But does not block popups triggered by clicking on buttons.

// popup blocked
window.open('https://javascript.info');

// popup allowed
button.onclick = () => {
  window.open('https://javascript.info');
};

So i had to bypass their blocking policy by programmatically clicking on the button after 5 seconds to still initiate the same popup.

So i decided to post this as a question and also answer it by myself for those that might be facing the same issue.

Step 1. Create a button, give it and ID and pass a function name on the onClick

<button id="buttonID" onclick="trigerPopup()"></button> 

Step 2 Create trigerPopup function

function trigerPopup(){
        alert("Hello I am poping up after 5 seconds");
        //your code goes here
}

Step 3 After 5 seconds, programmatically clicked on button

    window.setTimeout(function () {

        //this will trigger a click on the button
        const buttonID = document.getElementById('buttonID').click();


   }, 5000);

Thanks guys

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Step 1. Create a button, give it and ID and pass a function name on the onClick

<button id="buttonID" onclick="trigerPopup()"></button> 

Step 2 Create trigerPopup function

function trigerPopup(){
        alert("Hello I am poping up after 5 seconds");
        //your code goes here
}

Step 3 After 5 seconds, programmatically clicked on button

    window.setTimeout(function () {

        //this will trigger a click on the button
        const buttonID = document.getElementById('buttonID').click();


   }, 5000);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda